<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class BackAdmin extends Model
{
    use SoftDeletes;
    use HasFactory;

    protected $table = 'zfm_brokers';


    /**
     * ’展示信息
     * @return mixed
     */
    public static function show()
    {
        return self::query()->get(['username', 'email']);
    }

    /**
     * 删除数据
     * @param $id
     * @return int
     */
    public static function del($id, $idDate)
    {
        return self::where([$id => $idDate])->delete();
    }

    /**
     * 搜索方法
     * @param $data
     */
    public static function search($username, $where)
    {
        return self::where($username, 'like', "$where")->get(['username', 'email', 'created_at']);
    }

    /**
     * 修改方法
     * @param $id
     * @param $first
     * @param $data
     * @return mixed
     */
    public static function updates($id, $data)
    {
        $data = implode($data, '.');
        return self::where($id, $data['id'])->update($data);
    }
}
